package com.jfm.jfmm.collector.enums;

import cn.hutool.core.bean.BeanUtil;
import com.jfm.jfmm.collector.entity.collect.CollectParam;
import com.jfm.jfmm.collector.entity.collect.param.SNMPParam;
import com.jfm.jfmm.collector.entity.device.Device;
import com.jfm.jfmm.collector.entity.template.CollectTemplate;
import com.jfm.jfmm.collector.entity.template.SNMP;
import lombok.Getter;

/**
 * @author DYang
 * @since 2024-10-08 23:11
 * 采集协议枚举
 */
@Getter
public enum CollectorProtocol {

    SNMP("snmp"),
    HTTP("http"),
    ICMP("icmp"),
    UDP("udp"),
    TELNET("telnet"),
    ;


    private final String protocol;

    CollectorProtocol(String protocol) {
        this.protocol = protocol;
    }

    /**
     * 根据协议获取枚举
     * @param protocol 协议
     * @return 枚举
     */
    public static CollectorProtocol getByProtocol(String protocol) {
        if (protocol == null) {
            return null;
        }
        for (CollectorProtocol value : CollectorProtocol.values()) {
            if (protocol.equals(value.getProtocol())) {
                return value;
            }
        }
        return null;
    }

    /**
     * 根据协议获取对应采集参数
     *
     * @param device            设备
     * @param protocol          协议
     * @param template          模板
     * @return 采集参数
     */
    public static CollectParam getProtocol(Device device, String protocol, CollectTemplate template) {
        CollectParam param = new CollectParam();
        CollectorProtocol collectorProtocol = getByProtocol(protocol);
        switch (collectorProtocol) {
            case SNMP -> {
                SNMPParam snmpParam = new SNMPParam();
                SNMP snmp = device.getSnmp();
                if (snmp == null) return null;
            }
            case TELNET -> {
            }
        }
        return null;
    }


}
